package com.looookme.shaozhuo.uicompent;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.looookme.shaozhuo.mb_study.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Created by Shaozhuo on 2015/9/8.
 */
public class Ui_GridView extends Activity {
    private GridView mGridVie;
    int[] imgsId = new int[]{R.drawable.bg1, R.drawable.bg2, R.drawable.bg3, R.drawable.bg4, R.drawable.ball, R.drawable.item_icon};
    String[] titles = new String[]{"BG 1", "BG 2", "BG 3", "BG 4", "BG 5", "BG 6"};
    List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.uiupperlayout_gridview);

        initView();
    }

    private void initView() {
        mGridVie = (GridView)findViewById(R.id.uiupper_gridview);

        for(int i = 0; i < imgsId.length; i++){
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("image", imgsId[i]);
            map.put("title", titles[i]);

            listItems.add(map);
        }

        SimpleAdapter mAdapter = new SimpleAdapter(this, listItems, R.layout.uipperlayout_gridview_item, new String[]{"title", "image"}, new int[]{R.id.uiupper_gridview_title, R.id.uiupper_gridview_imageView});
        mGridVie.setAdapter(mAdapter);
    }

}
